<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">

		<style type="text/css">
			.ui-datalist-empty-message {
				/* height: 100px; */
				min-height: 100px;
			}
			
			.ui-datalist-content {
				/* height: 100px; */
				min-height: 100px;
			}
			
			.zdhb {
				background: #6197e6;
			}
			
			.qtyc {
				background: #c7c7c7;
			}
			
			.dwgz {
				background: #ffa988;
			}
			
			.zhtd {
				background: #fafbc0;
			}
			
			.ui-datatable-scrollable-header-box {
				margin-left: 0px;
				margin-right: 15px !important;
			}
		</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="formLog">
				<div class="box-header" id="queryDiv">		
					<p:outputLabel  value="隐患等级：" style="margin-left:10px;" />
					<h:selectOneMenu id="hdLevel" value="#{knowledgeBaseController.queryParam.hdLevel}"	style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseController.gradeList}" var="hdlItem" />
					</h:selectOneMenu>
					<p:outputLabel  value="隐患来源：" style="margin-left:10px;" />
					<h:selectOneMenu id="hdSource" value="#{knowledgeBaseController.queryParam.hdSource}"	style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseController.sourceList}" var="hdsItem" />
					</h:selectOneMenu>
					<p:outputLabel  value="问题归类：" style="margin-left:10px;" />
					<h:selectOneMenu id="quesType" value="#{knowledgeBaseController.queryParam.quesType}"	style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseController.quesList}" var="qtItem" />
					</h:selectOneMenu>	
					<p:outputLabel  value="原因归类：" style="margin-left:10px;" />
					<h:selectOneMenu id="reasonType" value="#{knowledgeBaseController.queryParam.reasonType}" style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems value="#{knowledgeBaseController.reasonList}" var="rtItem" />
					</h:selectOneMenu>				
					<p:commandButton icon="ui-icon-search" value="查询" id="query2" update="form:dataTb toolbar_s" oncomplete="getTableScrollHeight();" 
						actionListener="#{knowledgeBaseController.query()}"	style="margin-left:5px;">
					</p:commandButton>
					<p:commandButton icon="ui-icon-refresh" value="重置" style="margin-left:5px;"
						oncomplete="getTableScrollHeight();" actionListener="#{knowledgeBaseController.resetQuery}"
						update="form:dataTb  toolbar_s  hdLevel hdSource quesType reasonType ename" />
					<div class="box-tools pull-right">
						<button type="button" id="selectButton" title="高级查询" class="btn btn-default"
							onclick="onSelectDivClick();" style="margin-right: 50px;">
							<span id="selectButtonIcon" class="fa fa-caret-down">高级查询</span>
						</button>
					</div>
				</div>
				<div class="panel-collapse collapse" id="selectDiv">
					<p:outputLabel value="评价专家：" style="margin-left:20px;" />
				   	<p:autoComplete id="ename"  dropdown="true" placeholder="输入专家首字母查询" scrollHeight="400"
						value="#{knowledgeBaseController.queryParam.expertName}" style="margin-right:20px;"
					   completeMethod="#{knowledgeBaseController.complateExpert}"	>								  
					</p:autoComplete>
					<p:outputLabel for="popup3" value="登记时间："  style="margin-left:10px;"/>
					<p:calendar id="popup3" navigator="true" 
						value="#{knowledgeBaseController.queryParam.queryDateStart}"
						pattern="yyyy-MM-dd" maxdate="Date()" size="12">
					</p:calendar>
					<p:outputLabel for="popup4" value="至 "
						style="margin-right:5px;margin-left:5px;" />
					<p:calendar id="popup4" navigator="true"
						value="#{knowledgeBaseController.queryParam.queryDateEnd}"
						pattern="yyyy-MM-dd" maxdate="Date()" size="12">
					</p:calendar>
				</div>
				<div id="toolbarDiv">
					<p:toolbar id="toolbar_s">
						<f:facet name="left">
							<p:growl id="msgsLog" showDetail="true" />
							<p:commandButton value="新增"  icon="ui-icon-plus"
							rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_dxzsk_xz')}"
							 oncomplete="PF('addDiaLog').show()"
							 actionListener="#{knowledgeBaseController.create}"
							 update=":editForm:expertName"
						      />
							<p:commandButton update="editForm:editDetailLg form:dataTb"
								oncomplete="PF('editDlgLog').show()"
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_dxzsk_bj')}" icon="ui-icon-pencil"
								value="编辑" disabled="#{knowledgeBaseController.selectKb == null}">
								<f:setPropertyActionListener value="#{knowledgeBaseController.selectKb}"
									target="#{knowledgeBaseController.selectKb}"
									rendered="#{s:hasPermission(session,'bhyx_bhrb_ddyxrz_bj')}" />
							</p:commandButton>
							<p:commandButton value="删除" icon="ui-icon-trash"
								update="form:dataTb  formLog:msgsLog toolbar_s"
								actionListener="#{knowledgeBaseController.delete}"
								disabled="#{knowledgeBaseController.selectKb == null}" oncomplete="getTableScrollHeight();"
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_dxzsk_sc')}">
								<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
							</p:commandButton>
							<!-- <p:commandButton value="选择知识" icon="ui-icon-extlink" actionListener="#{knowledgeBaseController.chooseKnowledge()}">
							<p:ajax event="dialogReturn"  listener="#{knowledgeBaseController.onSelectorChosen}"  />
							</p:commandButton> -->
						</f:facet>
					</p:toolbar>
				</div>
			</h:form>
		</div>
		<div id="infoDiv" class="box box-solid with-border">
			<h:form id="form">
				<p:growl id="msgs" showDetail="true" />
				<p:dataTable id="dataTb" var="item" value="#{knowledgeBaseController.kbs}"
					selection="#{knowledgeBaseController.selectKb}" rowKey="#{item.id}" style="margin-bottom:0"
					emptyMessage="无记录" rows="20" paginator="true" rowIndexVar="ite"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} 
								{RowsPerPageDropdown}"
					widgetVar="dataTb" scrollable="true" 
					rowsPerPageTemplate="20,50,100" paginatorPosition="bottom">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{knowledgeBaseController.kbs.size()} 条记录" style="margin-right:20px;"></p:outputLabel>
					</f:facet>
					<p:ajax event="rowSelectRadio" listener="#{knowledgeBaseController.RowSelect}"
						update="formLog:toolbar_s"></p:ajax>
					<p:column selectionMode="single" width="10" style="text-align:center" />
					<p:column width="3" headerText="序号 ">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<!-- <p:column width="10" headerText="专家账号名称">
						<h:outputText value="#{item.expertCode}" />
					</p:column> -->
					<p:column width="8" headerText="专家">
						<h:outputText value="#{item.expertName}" />
					</p:column>
					<p:column width="30" headerText="记录时间">
						<h:outputText value="#{item.createdTime}">
							<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" />
						</h:outputText>
					</p:column>
					<p:column width="8" headerText="管辖专业">
						<h:outputText value="#{item.jSpecialty}" />
					</p:column>
					<p:column width="8" headerText="隐患等级">
						<h:outputText value="#{item.hiddenDangerGrade}" />
					</p:column>
					<p:column width="10" headerText="问题归类">
						<h:outputText value="#{item.hiddenDangerQuesClass}" />
					</p:column>
					<p:column width="10" headerText="原因归类">
						<h:outputText value="#{item.hiddenDangerReasonClass}" />
					</p:column>
					<p:column width="8" headerText="隐患来源">
						<h:outputText value="#{item.hiddenDangerSources}" />
					</p:column>
					<p:column width="120" headerText="隐患描述">
						<h:outputText value="#{item.hiddenDangerDesc}"/>
					</p:column>
					<p:column width="30" headerText="整改意见">
						<h:outputText value="#{item.rectificationPlan}" />
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="editForm">
				<p:dialog widgetVar="editDlgLog" id="editDlgLog" header="编辑" modal="true" width="800"
					height="500">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" icon="ui-icon-disk" update="form:dataTb formLog:msgsLog"
								oncomplete="PF('editDlgLog').hide();getTableScrollHeight()"
								actionListener="#{knowledgeBaseController.update}" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel id="editDetailLg">
						<p:panelGrid rendered="#{not empty knowledgeBaseController.selectKb}" style="width:100%">
							<p:row>							
								<p:column>
									<h:outputText value="专家:" />
								</p:column>
								<p:column>
									<p:inputText label="content" required="true" requiredMessage="专家为自动填充项"
										value="#{knowledgeBaseController.selectKb.expertName}" style="width:100%;">
									</p:inputText>
								</p:column>
								<p:column>
									<h:outputText value="时间:" />
								</p:column>
								<p:column>
									<p:calendar value="#{knowledgeBaseController.selectKb.createdTime}" navigator="true"
										pattern="yyyy-MM-dd HH:mm:ss" showHour="true" showMinute="true" showSecond="true" />
								</p:column>
							</p:row>
							<p:row>							
								<p:column>
									<h:outputText value="问题归类:" />
								</p:column>
								<p:column>
								     <p:autoComplete  value="#{knowledgeBaseController.selectKb.hiddenDangerQuesClass}"
							        	completeMethod="#{knowledgeBaseController.completeHiddenDangerQuesClass}" 
							    	    scrollHeight="400" dropdown="true" >
							    	</p:autoComplete>
								</p:column>
								<p:column>
									<h:outputText value="原因归类:" />
								</p:column>
								<p:column>
								 <p:autoComplete  value="#{knowledgeBaseController.selectKb.hiddenDangerReasonClass}"
							        	completeMethod="#{knowledgeBaseController.completeHiddenDangerReasonClass}" 
							    	    scrollHeight="400" dropdown="true" >
							    	</p:autoComplete>
								</p:column>
							</p:row>
							<p:row>							
								<p:column>
									<h:outputText value="隐患等级:" />
								</p:column>
								<p:column>
								    <p:autoComplete  value="#{knowledgeBaseController.selectKb.hiddenDangerGrade}"
							    	completeMethod="#{knowledgeBaseController.completeHiddenDangerGrade}" 
							    	scrollHeight="400" dropdown="true" >
							    	</p:autoComplete>
								</p:column>
								<p:column>
									<h:outputText value="隐患来源：" />
								</p:column>
								<p:column>
								      <p:autoComplete  value="#{knowledgeBaseController.selectKb.hiddenDangerSources}"
								      completeMethod="#{knowledgeBaseController.completeHiddenDangerSources}"
								       scrollHeight="400" dropdown="true" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputText value="隐患描述:" />
								</p:column>
								<p:column colspan="5">
									<p:inputTextarea rows="8" label="content" autoResize="false"
										value="#{knowledgeBaseController.selectKb.hiddenDangerDesc}" style="width:100%;">
									</p:inputTextarea>
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputText value="整改方案:" />
								</p:column>
								<p:column colspan="5">
									<p:inputTextarea rows="8" label="content" autoResize="false"
										value="#{knowledgeBaseController.selectKb.rectificationPlan}" style="width:100%;">
									</p:inputTextarea>
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
				<!-- 新增dialog -->
				<p:dialog widgetVar="addDiaLog" id="addDiaLog" header="新增编辑" modal="true" width="800"
					height="600">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" icon="ui-icon-disk" update="form:dataTb formLog:msgsLog"
								oncomplete="PF('addDiaLog').hide();getTableScrollHeight()"
								actionListener="#{knowledgeBaseController.saveNew}" />
							<p:commandButton value="取消" icon="ui-icon-cancel" oncomplete="PF('addDiaLog').hide()" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel id="editDetailLg1">
						<p:panelGrid  style="width:100%">
							<p:row>							
								<p:column>
									<h:outputText value="专家:" />
								</p:column>
								<p:column>
								   
								    <p:autoComplete id="expertName"  dropdown="true" placeholder="输入专家首字母查询" scrollHeight="400"
										value="#{knowledgeBaseController.created.expertName}" style="margin-right:10px"
									   completeMethod="#{knowledgeBaseController.complateExpert}"	>
									   <p:ajax event="itemSelect" listener="#{knowledgeBaseController.associationExpert}" 
									   update=":editForm:jSpecialty  :editForm:hiddenDangerSources" />
									</p:autoComplete>
								</p:column>
								<p:column>
									<h:outputText value="管辖专业:" />
								</p:column>
								<p:column>
								   <p:autoComplete id="jSpecialty" value="#{knowledgeBaseController.created.jSpecialty}"
							        	completeMethod="#{knowledgeBaseController.completeHiddenDangerJSpecialty}" 
							    	    scrollHeight="400" dropdown="true" >
							    	</p:autoComplete>
								</p:column>
							</p:row>
							<p:row>							
								<p:column>
									<h:outputText value="问题归类:" />
								</p:column>
								<p:column>
								     <p:autoComplete id="hiddenDangerQuesClass" value="#{knowledgeBaseController.created.hiddenDangerQuesClass}"
							        	completeMethod="#{knowledgeBaseController.completeHiddenDangerQuesClass}" 
							    	    scrollHeight="400" dropdown="true" >
							    	<p:ajax event="itemSelect" listener="#{knowledgeBaseController.association}" update=":editForm:hiddenDangerReasonClass" />
							    	</p:autoComplete>
								</p:column>
								<p:column>
									<h:outputText value="原因归类:" />
								</p:column>
								<p:column>
								 <p:autoComplete id="hiddenDangerReasonClass" value="#{knowledgeBaseController.created.hiddenDangerReasonClass}"
							        	completeMethod="#{knowledgeBaseController.completeHiddenDangerReasonClass}" 
							    	    scrollHeight="400" dropdown="true" >
							    	</p:autoComplete>
								</p:column>
							</p:row>
							<p:row>							
								<p:column>
									<h:outputText value="隐患等级:" />
								</p:column>
								<p:column>
								    <p:autoComplete id="hiddenDangerGrade" value="#{knowledgeBaseController.created.hiddenDangerGrade}"
							    	completeMethod="#{knowledgeBaseController.completeHiddenDangerGrade}" 
							    	scrollHeight="400" dropdown="true" >
							    	</p:autoComplete>
								</p:column>
								<p:column>
									<h:outputText value="隐患来源：" />
								</p:column>
								<p:column>
								      <p:autoComplete id="hiddenDangerSources" value="#{knowledgeBaseController.created.hiddenDangerSources}"
								      completeMethod="#{knowledgeBaseController.completeHiddenDangerSources}"
								       scrollHeight="400" dropdown="true" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputText value="隐患描述:" />
								</p:column>
								<p:column colspan="5">
									<p:inputTextarea rows="8" label="content" autoResize="false"
										 style="width:100%;" value="#{knowledgeBaseController.created.hiddenDangerDesc}" >
									</p:inputTextarea>
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputText value="整改方案:" />
								</p:column>
								<p:column colspan="5">
									<p:inputTextarea rows="8" label="content" autoResize="false"
										 style="width:100%;"  value="#{knowledgeBaseController.created.rectificationPlan}">
									</p:inputTextarea>
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
			</h:form>
			
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script type="text/javascript" src="/resources/plugins/layer/layer.js" />
		<script type="text/javascript" src="/resources/js/mymodal.js" />
		<script src="/resources/js/tables/singleScrollTable.js" />
	</ui:define>
</ui:composition>